<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>{block name="title"}{/block}</title>

    <!--wangEditor5样式-->
    <link rel="stylesheet" href="__ROOT__/public/static/css/wangeditor.css">

    <link rel="stylesheet" href="__ROOT__/public/static/layui/css/layui.css">

    <!--
    为了隐藏public路径，
    所以把public路径下的index.php入口文件
    移动到了根目录，所以使用__ROOT__常量时需要
    加上public目录
    -->
<!--修改全局laber-->
    <style>
        .layui-form-label{
            font-size: 0.8rem;
        }
    </style>

</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">EasyCms</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>

            <li class="layui-nav-item layui-hide-xs {block name='index'}{/block}">

                <a href="{:url('admin/index/index')}"><i class="layui-icon layui-icon-windows" ></i> &nbsp;&nbsp;欢迎使用本cms系统</a>

            </li>





        </ul>
        <ul class="layui-nav layui-layout-right" lay-bar="disabled">
            <li class="layui-nav-item  " lay-unselect>

                <a href="{:url('admin/Project/Preview')}" target="_blank"><i class="layui-icon layui-icon-home" ></i> &nbsp;&nbsp;预览首页</a>

            </li>

            <li class="layui-nav-item " lay-unselect>

                <a style="cursor: pointer"  onclick="update()"><i class="layui-icon layui-icon-refresh" ></i> &nbsp;&nbsp;更新首页</a>

            </li>

            <li class="layui-nav-item " lay-unselect>

                <a style="cursor: pointer" onclick="clean()"><i class="layui-icon layui-icon-note" ></i> &nbsp;&nbsp;清除缓存</a>

            </li>

            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="__ROOT__/public/static/img/tx.jpg" class="layui-nav-img">
                    管理员
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="{:url('admin/login/quit')}">退出登录</a></dd>
                    <dd><a style="cursor: pointer" onclick="Account_set()">账号设置</a></dd>
                </dl>

            </li>

        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">项目</a>
                    <dl class="layui-nav-child">
                        <dd><a class="{block name='project'}{/block} " href="{:url('admin/project/index')}"><i class="layui-icon layui-icon-set"></i>   项目设置</a></dd>
                        <dd><a class="{block name='update'}{/block}" href="{:url('admin/update/index')}"><i class="layui-icon layui-icon-read"></i> 更新日志</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">内容管理</a>
                    <dl class="layui-nav-child">
                        <dd><a class="{block name='column'}{/block}" href="{:url('admin/column/index')}"><i class="layui-icon layui-icon-tabs"></i> 栏目管理</a></dd>
                        <dd><a class="{block name='artManage'}{/block}" href="{:url('admin/Artmanage/index')}"><i class="layui-icon layui-icon-layouts"></i> 文章管理</a></dd>
                        <dd><a class="{block name='article'}{/block}" href="{:url('admin/Article/index')}"><i class="layui-icon layui-icon-release"></i> 文章发布</a></dd>
                    </dl>
                </li>

            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            {block name='nr'}

            {/block}
        </div>
    </div>

<!--    <div class="layui-footer">-->
<!--        &lt;!&ndash; 底部固定区域 &ndash;&gt;-->
<!--        底部固定区域-->
<!--    </div>-->
</div>
<script src="__ROOT__/public/static/layui/layui.js"></script>
<script src="__ROOT__/public/static/js/jquery-1.9.1.min.js"></script>
<script src="__ROOT__/public/static/js/jquery.Form.js"></script>
<script src="__ROOT__/public/static/layui/treeTable.js"></script>
<script src="__ROOT__/public/static/js/wangeditor.js"></script>

<script>
    //JS
    layui.use(['element', 'layer', 'util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,util = layui.util
            ,$ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }

        });

    });

    //账号设置
    function Account_set(){
        var addHtml = '<form id="form1" class="layui-form"  style="width:460px; margin-top: 20px;">\
                           <div class="layui-form-item">\
                             <label class="layui-form-label">用户名</label>\
                             <div class="layui-input-block">\
                             \<input type="hidden" id="id"  name="id" lay-verify="title" autocomplete="off"  class="layui-input">\
                               <input type="text" id="username" name="username" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input">\
                             </div>\
                           </div>\
                           \ <div class="layui-form-item">\
                             <label class="layui-form-label">新密码</label>\
                             <div class="layui-input-block">\
                               <input type="password" name="password" lay-verify="title" autocomplete="off" placeholder="请输入新密码" class="layui-input">\
                             </div>\
                           </div>\
                       </form>\
              \
               ';


        layui.use('layer', function(){
            var layer = layui.layer;


            layer.open({
                type: 1,
                title: '账号设置',
                content: addHtml,
                area:['500px','250px'],
                btn: ['保存', '取消'],
                success:function (){
                    $.ajax({
                        url:"{:url('admin/User/user_show')}",
                        type:"get",
                        success:function (res){
                            //打开时渲染数据
                            res=$.parseJSON(res)
                            var username=res['username']
                            var id=res['id']
                            $("#id").attr("value",id)
                            $("#username").attr("value",username)

                        }
                    })

                }, yes:function (layIndex) {
                    $('#form1').ajaxSubmit({
                        type:"PUT",
                        url:"{:url('admin/User/set_user')}",
                        success: function (rsp) {
                            rsp=$.parseJSON(rsp)
                            if (rsp['code'>0]){
                                layer.msg(rsp['message'])
                                layer.close(layIndex)
                            }else {
                                layer.msg(rsp['message'])
                            }


                        }
                    });
                }


            });
        });

    }

    //更新主页
    function update(){
        $.ajax({
            url:"{:url('admin/project/updateHomePage')}",
            type:"POST",
            success:function (res) {
                res=$.parseJSON(res)
                layer.msg(res)
            }


        })

    };

    //清除缓存
    function clean(){
        $.ajax({
            url:"{:url('admin/project/cache_clear')}",
            type:"POST",
            success:function (res) {
                res=$.parseJSON(res)
                layer.msg(res)
            }


        })

    }
</script>

{block name='js'}{/block}
</body>
</html>